<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>回执信息录入（添加）</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script type="text/javascript" src="../../js/jquery-2.0.3.min.js"></script>
    <link rel="stylesheet" href="../../layui/css/layui.css"  media="all">
</head>
<body>


<!--表单-->
<form id="myform" class="layui-form" method="" action="" style="margin-top: 30px;">

    <input type="hidden" name="line" id="line" >
    <!--获取当前线路编号-->
    <input type="hidden" name="line_id">
    <!--//获取当前登录巡检员的账号-->

    <!--员工姓名-->
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 120px">任务编号：</label>
        <div class="layui-input-inline" style="width: 250px">
            <input type="text" name="task_id" lay-verify="required|task_id" disabled="disabled" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label" style="width: 120px">完好率：</label>
        <div class="layui-input-inline" style="width: 250px">
            <input type="text" name="intact" lay-verify="required|intact" autocomplete="off" class="layui-input">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 120px">路线名称：</label>
        <div class="layui-input-inline" style="width: 250px">
            <input type="text" name="line_name" lay-verify="required|line_name" disabled="disabled" autocomplete="off" class="layui-input">
        </div>

        <label class="layui-form-label" style="width: 120px">杆塔编号：</label>
        <div class="layui-input-inline" style="width: 250px">
            <select name="tower_id" id="tower_id" lay-verify="required" lay-filter="xmFilter">
                <option value=""></option>
            </select>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 120px">发现人员：</label>

        <div class="layui-input-inline" style="width: 250px">
            <input type="text" name="user_name" lay-verify="required|user_name" disabled="disabled" autocomplete="off" class="layui-input">
        </div>

        <label class="layui-form-label" style="width: 120px">发现日期：</label>
        <div class="layui-input-inline" style="width: 250px">
            <input type="text" name="find_time" id="data" lay-verify="find_time"  disabled="disabled" autocomplete="off" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 120px">缺陷内容：</label>
        <div class="layui-input-inline" style="width: 250px">
            <select name="defect_id" lay-verify="required" lay-filter="xmFilter">
                <option value=""></option>
                <option value="1">叉梁断开</option>
                <option value="2">拦河线断裂</option>
                <option value="3">绝缘子爆破</option>
                <option value="4">杆塔倾斜</option>
                <option value="5">吊杆变形</option>
                <option value="6">其他</option>
            </select>
        </div>

        <label class="layui-form-label" style="width: 120px">缺陷级别：</label>
        <div class="layui-input-inline" style="width: 250px">
            <select name="defect_grade" lay-verify="required" lay-filter="xmFilter">
                <option value=""></option>
                <option value="1">一般</option>
                <option value="2">严重</option>
                <option value="3">紧急</option>
            </select>
        </div>

    </div>

    <!--备注-->
    <div class="layui-form-item layui-form-text" style="margin-left: 12px">
        <label class="layui-form-label">缺陷描述：</label>
        <div class="layui-input-block">
            <textarea  class="layui-textarea"  name="defect_des" style="width: 270px"></textarea>
        </div>
    </div>

    <!--提交按钮-->
    <div class="layui-form-item" style="padding-left: 500px; margin-top:-200px;padding-top: -500px;">
        <div class="layui-input-block">
            <button type="button" class="layui-btn" lay-filter="edit_inspetion" lay-submit="edit_inspetion" style="margin-left: -60px;">上传回执</button>
            <button type="button" class="layui-btn layui-btn-normal" id="quit"style="margin-left: 60px">取消</button>
        </div>
    </div>

</form>



<!--引入本地layui.js-->
<script src="../../layui/layui.js" charset="utf-8"></script>

<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //动态给巡检员框select中option添加巡检员内容
        var data=$("#line").val();
        $.ajax({
            url:"/DefectSelect.do",
            data:{line_id:data},
            dataType:"json",
            type: 'post',
            success: function (data) {
                console.log(data);//下面会提到这个data是什么值
                //使用循环遍历，给下拉列表赋值
                $.each(data.data, function (index, value) {
                    $('#tower_id').append(new Option(value.tower_name,value.tower_name));// 下拉菜单里添加元素
                });
                layui.form.render("select");//重新渲染 固定写法
            }
        });

        //日期
        laydate.render({

            elem: '#data',// input里时间的Id    .charAt(new Date().getDay()
            value:new Date(),
            done: function (value, date) {
            }
        });
        laydate.render({
            elem: '#date1'
        });

        //监听提交
        form.on('submit(edit_inspetion)', function(data){
//            alert("编辑按钮点击成功"+data.inspector_account)
            $.ajax({
                url:"/Edit_CarriedInspe.do",
                type:"post",
                data:JSON.stringify(data.field),
                dataType:"json",
                success:function (result) {
                    if (result.code == 200){
                        layer.msg("编辑成功,3秒后关闭当前以页...",{icon:1,time:3000,shade:0.4},function() {
                            parent.layer.close(parent.layer.index);
                        });
                    }else if (result.code == 500){
                        alert(result.message);
                    }else if (result.code == 405){
                        layer.msg(result.msg,{icon:5});
                    }
                }
            });
            return false;
        });

    });
</script>

<script>
    //取消线路编辑
    $(document).on('click',"#quit",function () {
        parent.layer.close(parent.layer.index);
    });
</script>



</body>
</html>